﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Configuration;

namespace XCT.Functions
{
    public class clsDungChung
    {
        #region "Bien"

        public static string strUser = "";
        public static string strBar = "CLLH...BTP...EDC...DBG";
        public static string strbaocao = "";
        public static string strduongdan = ConfigurationSettings.AppSettings.Get("PathReport");
        public static string pSoLSX;
        public static string pDoLy;
        public static string pTuanKH;
        public static string pThang;
        public static string pNam;
        public static string pCongDoan;
        public static int ploai;
        public static string pTuNgay;
        public static string pDenNgay;
        public static string pCa;
        public static string pMaMau;
        public static string pMaCT;
        public static string pCoso;
        public static string pChungloai;
        public static string pHoaVan;

        #endregion

        //Hàm edit grid
        public void editGrid(DevExpress.XtraGrid.Views.Grid.GridView grdView, Boolean bisMoKhoa, ArrayList arr)
        {
            try
            {
                if (arr != null)
                {
                    for (int intItem = 0; intItem < arr.Count; intItem++)    //Mở khóa những cột chỉ định
                    {
                        grdView.Columns[arr[intItem].ToString()].OptionsColumn.AllowEdit = bisMoKhoa;
                    }
                }
                else
                {
                    for (int i = 0; i < grdView.Columns.Count; i++)
                        grdView.Columns[i].OptionsColumn.AllowEdit = bisMoKhoa;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }

        //Chuyen font VNI sang UNICODE
        public string ConvertVNI2Unicode(string strInput)
        {
            int[] maAcii = new int[134]{7845, 7847, 7849, 7851, 7853, 226, 7843, 227, 7841, 7855, 7857, 7859,
                7861, 7863, 259, 250, 249, 7911, 361, 7909, 7913, 7915, 7917, 7919, 7921, 432, 7871, 7873, 7875, 
                7877, 7879, 234, 233, 232, 7867, 7869, 7865, 7889, 7891, 7893, 7895, 7897, 7887, 245, 7885, 7899,
                7901, 7903, 7905, 7907, 417, 237, 236, 7881, 297, 7883, 253, 7923, 7927, 7929, 7925, 273, 7844, 7846,
                7848,7850, 7852, 194, 7842, 195, 7840, 7854, 7856, 7858, 7860, 7862, 258, 218, 217, 7910, 360, 7908, 
                7912, 7914, 7916, 7918, 7920, 431, 7870, 7872, 7874, 7876, 7878, 202, 201, 200, 7866, 7868, 7864,
                7888, 7890, 7892, 7894, 7896, 7886, 213, 7884, 7898, 7900, 7902, 7904, 7906, 416, 205, 204, 7880,
                296, 7882, 221, 7922, 7926, 7928, 7924, 272, 225, 224, 244, 243, 242, 193, 192, 212, 211, 210};

            string[] Vni = new string[134]{"aá", "aà", "aå", "aã", "aä", "aâ", "aû", "aõ", "aï", "aé", "aè",
                            "aú", "aü", "aë", "aê", "uù", "uø", "uû", "uõ", "uï", "öù", "öø", "öû", "öõ",
                            "öï", "ö", "eá", "eà", "eå", "eã", "eä", "eâ", "eù", "eø", "eû", "eõ", "eï",
                            "oá", "oà", "oå", "oã", "oä", "oû", "oõ", "oï", "ôù", "ôø",
                            "ôû", "ôõ", "ôï", "ô", "í", "ì", "æ", "ó", "ò", "yù", "yø", "yû", "yõ", "î",
                            "ñ", "AÁ", "AÀ", "AÅ", "AÃ", "AÄ", "AÂ", "AÛ", "AÕ",
                            "AÏ", "AÉ", "AÈ", "AÚ", "AÜ", "AË", "AÊ", "UÙ", "UØ", "UÛ", "UÕ",
                            "UÏ", "ÖÙ", "ÖØ", "ÖÛ", "ÖÕ", "ÖÏ", "Ö", "EÁ", "EÀ", "EÅ",
                            "EÃ", "EÄ", "EÂ", "EÙ", "EØ", "EÛ", "EÕ", "EÏ", "OÁ", "OÀ", "OÅ",
                            "OÃ", "OÄ", "OÛ", "OÕ", "OÏ", "ÔÙ", "ÔØ", "ÔÛ",
                            "ÔÕ", "ÔÏ", "Ô", "Í", "Ì", "Æ", "Ó", "Ò", "YÙ", "YØ", "YÛ", "YÕ",
                            "Î", "Ñ", "aù", "aø", "oâ", "où", "oø", "AÙ", "AØ", "OÂ", "OÙ", "OØ"};
 
            string result = strInput;
            for (int i = 0; i < 134; i++)
            {
                result = result.Replace(Vni[i], Convert.ToChar(maAcii[i]).ToString());
            }
            return result;
        }
    }
}
